<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>国省自检--${fns:getConfig('productName')}</title>
<link rel="stylesheet" href="${ctx}/styles/gsjcss/common.css">
<script type="text/javascript">
function btnClick(){
	var url = '${ctx}/roadNetProject/search.do?projectId=${fns:encodeParamUrl(projectId)}&menuId=${fns:encodeParamUrl(menuId)}';
	var data = {};
	if($('#btnSearch').length>0){ //有搜索按钮的情况下 获取条件进行搜索
		//将条件提取出来 
		//将条件存入data中
		//ajax请求   得到数据
		data['retrieval'] = getJson('condition');
		loadData(url,data);
	} else {
		loadData(url,data);
	}
}
//ajax执行成功之后的回调方法
function loadDataToTable(data){
	var attment = data['att'];
	var flag = data['flag'];
	var yearList = data['yearList'];
	var classifyList = data['classifyList'];
	var abList = data['abList'];
	loadAttachment(attment);
	
	//返回综合信息
	if($('#yearSum') != undefined){
		var result="";
		var thead = '<tr><th>年份</th><th>各类补助资金总额(万元)</th><th>配套资金总额(万元)</th><th>配套资金比例(%)</th></tr>';
		//每次搜索前清空表格
		$('#yearSum tbody').empty();
		for (var i = 0; i < yearList.length-1; i++) {
			result += '<tr><td>'+yearList[i].year+'</td><td>'+yearList[i].selfRaised+'</td><td>'+yearList[i].subsidy+'</td><td>'+yearList[i].rate+'%</td></tr>';
		}
		$('#yearSum thead').append(thead);
		$('#yearSum tbody').append(result);
	}
	//返回各个项目类型年度情况
	if ($('#abwqzhfz-1') != undefined) {
		$('#abwqzhfz-1 tbody').empty();
	}
	if ($('#abwqzhfz-2') != undefined) {
		$('#abwqzhfz-2 tbody').empty();
	}
	if ($('#ababwqzhfz-3') != undefined) {
		$('#abwqzhfz-3 tbody').empty();
	}
	
	getProjectTable(classifyList);
	
	
	if (flag) {
		$('#checkResult #check').empty();
		var countent = '<table id="check" style="width:98%;text-align:center;margin-top:5px;" border="1"><thead>'+
					   '<tr><td>序号</td><td>项目名称</td><td>部补助资金(万元)</td><td>配套资金(万元)</td><td>配套比例(%)</td><td>得分</td></tr>'+
					   '</thead><tbody> </tbody></table>';
		$('#checkResult').append(countent);
		var result = ''; 
		for (var i = 0; i < abList.length; i++) {
			if (i == 0) {
				result += '<tr><td>'+parseInt(i+1)+'</td><td>'+abList[i].projectName+'</td><td>'+abList[i].subsidyAmount+'</td><td>'+abList[i].selfRaised+'</td><td>'+abList[i].rate+'%</td><td rowspan='+abList.length+'>'+data['temp']+'</td></tr>';
			}else {
				result += '<tr><td>'+parseInt(i+1)+'</td><td>'+abList[i].projectName+'</td><td>'+abList[i].subsidyAmount+'</td><td>'+abList[i].selfRaised+'</td><td>'+abList[i].rate+'%</td></tr>';
			}
		}
		
		$('#checkResult #check tbody').append(result);
	}
	
	if ($('#checkResult') != undefined) {
		$('#checkResult #sum').empty();
		var result ='';
		for (var i = 0; i < yearList.length; i++) {
			result += '<tr><td>'+yearList[i].year+'</td><td>'+yearList[i].selfRaised+'</td><td>'+yearList[i].subsidy+'</td><td>'+yearList[i].rate+'%</td>';
			if(i == 0) {
				result += '<td class="sumTd" rowspan= '+yearList.length+'>'+data['sum']+'</td><td class="perTd" rowspan= '+yearList.length+'>'+data['percent']+'%</td>';
			}
			result += '</tr>';
		}
		var countent = '<table id="sum" style="width:98%;text-align:center;margin-top:5px;" border="1"><thead><tr>'+
					   '<th>年份</th><th>各类补助资金总额(万元)</th><th>配套资金总额(万元)</th><th>配套资金比例(%)</th><th>总分</th><th>完善度</th></tr>'+
					   '</thead><tbody>'+result+'</tbody></table>';
		$('#checkResult').append(countent);
		
	}
	
}
//各个类型的项目年度情况
function getProjectTable(classifyList){
	var result1 = "";
	var result2 = "";
	var result3 = "";
	for (var i = 0; i < classifyList.length; i++) {
		if (classifyList[i].label == 1) {
			result1 += "<tr><td class='t-font'>"+classifyList[i].year+"</td><td>"+classifyList[i].all+"</td><td>"+classifyList[i].finished+"</td><td>"+classifyList[i].spare+"</td><td>"+classifyList[i].finishRate+"%</td>"+
					   "<td>"+classifyList[i].total+"</td><td>"+classifyList[i].subsidy+"</td><td>"+classifyList[i].selfRaised+"</td><td>"+classifyList[i].rate+"%</td></tr>";
		} else if ( classifyList[i].label == 2 ) {
			result2 += "<tr><td class='t-font'>"+classifyList[i].year+"</td><td>"+classifyList[i].all+"</td><td>"+classifyList[i].finished+"</td><td>"+classifyList[i].spare+"</td><td>"+classifyList[i].finishRate+"%</td>"+
			  		   "<td>"+classifyList[i].total+"</td><td>"+classifyList[i].subsidy+"</td><td>"+classifyList[i].selfRaised+"</td><td>"+classifyList[i].rate+"%</td></tr>";
		} else if ( classifyList[i].label == 3 ) {
			result3 += "<tr><td class='t-font'>"+classifyList[i].year+"</td><td>"+classifyList[i].all+"</td><td>"+classifyList[i].finished+"</td><td>"+classifyList[i].spare+"</td><td>"+classifyList[i].finishRate+"%</td>"+
			  		   "<td>"+classifyList[i].total+"</td><td>"+classifyList[i].subsidy+"</td><td>"+classifyList[i].selfRaised+"</td><td>"+classifyList[i].rate+"%</td></tr>";
		}  
	}
	$('#abwqzhfz-1 tbody').append(result1);
	$('#abwqzhfz-2 tbody').append(result2);
	$('#abwqzhfz-3 tbody').append(result3);
}


</script>
</head>
<body>
	<div id="x_top"></div>
	<tags:message content="${msg}" />
	<c:if test="${not empty checkTable.id}">
		<div style="text-align:center">
			<a href="javascript:void(0);" class="btn btn-primary" onclick="downWord('${ctx}/roadNetProject/downWord.do?projectId=${fns:encodeParamUrl(projectId)}&menuId=${fns:encodeParamUrl(menuId)}');" id= "btnDown" role="button" ><div id="x_v"></div></a>
		</div>
	</c:if>
	<form id="checkForm" class="form-horizontal"  method="POST"  name="checkForm" action="${ctx}/roadNetProject/save.do?left=${fns:encodeParam(left)}&parentId=${fns:encodeParam(parentId)}&projectId=${fns:encodeParam(projectId)}&menuId=${fns:encodeParam(menuId)}&leftChild=${fns:encodeParam(leftChild)}">
		<input type="hidden" name="token" value="${token}">
		<div id="show">
			<div id="showTable" class="showTable">
				<jsp:include page="/WEB-INF/views/check/common.jsp"/> 
				<div class="model">
					<div>
						<legend>三、检查条件及设置</legend>
						<div class="content-title" id="condition">
							<div style="float:left;margin-right:10px;">
								<div>
									<span>安保工程：</span>
		                            <select name="abProjectId" id="abProjectId" style='margin-right: 20px;width: 250px;'>
		                                <option value="">请选择</option>
		                                <c:forEach items="${fns:getReconstruction(projectId)}" var="itemName" varStatus="idxStatus">
		                                	<c:if test="${itemName.projectType == 1}">
			                                    <option value="${itemName.id}">${itemName.projectName}</option>
		                                	</c:if>
		                                </c:forEach>
		                       		</select>
		                       		<span>危桥改造：</span>
		                            <select name="wqProjectId" id="wqProjectId" style='margin-right: 20px;width: 250px;'>
		                                <option value="">请选择</option>
		                                <c:forEach items="${fns:getReconstruction(projectId)}" var="itemName" varStatus="idxStatus">
		                                    <c:if test="${itemName.projectType == 2}">
		                                    	<option value="${itemName.id}">${itemName.projectName}</option>
		                                    </c:if>
		                                </c:forEach>
		                       		 </select>
		                       	</div>
		                       	<div style="margin-top:20px;">
		                       		 <span>灾害防治：</span>
		                             <select name="zhProjectId" id="zhProjectId" style='margin-right: 20px;width: 250px;'>
		                                <option value="">请选择</option>
		                                <c:forEach items="${fns:getReconstruction(projectId)}" var="itemName" varStatus="idxStatus">
		                                    <c:if test="${itemName.projectType == 3}">
		                                    	<option value="${itemName.id}">${itemName.projectName}</option>
		                                    </c:if>
		                                </c:forEach>
		                       		  </select>
									<span>4年配套总比例达到55%得分<font style="color:red;">*</font>：</span>
									<input type='text' name = "yearFull" id="yearFull" value="4" class="required conInput"/>
								</div>
								<div style="margin-top:20px;">
									<span>4年配套总比例每降低1个百分点扣分<font style="color:red;">*</font>：</span>
									<input type='text' name = "yearPart" id="yearPart" value="0.5" class="required conInput"/>
									<span>项目执行情况满分<font style="color:red;">*</font>：</span>
									<input type='text' name = "poitMark" id="poitMark" value="2" class="required conInput"/>
								</div>
								<div style="margin-top:20px">
									<span>每个项目降低1个百分点扣分<font style="color:red;">*</font>：</span>
									<input type='text' name = "reserveMark" id="reserveMark" value="0.2" class="required conInput"/>
								</div>
							</div>
							<div id="x_s" style="float:right">
								<div class="x_ico"></div>
								<a href="#javascript:void(0)" onclick= "btnClick();"  id= "btnSearch" role="button" >搜索&nbsp;</a>
							</div>
						</div>
					</div>
				</div>
				<div class="model">
					<div>
						<legend>四、检索结果</legend>
						<div class="content-title">
							<div class="tabbox">
								<div class="tab">
									<a href="javascript:;" class="on">综合记录</a>
									<a href="javascript:;" >安防工程</a>
									<a href="javascript:;" >危桥改造</a>
									<a href="javascript:;" >灾害防治</a>
									<c:forEach items="${childMenuList}" var="menu"  varStatus="idxStatus">
											<a href="javascript:;">${menu.name}</a>
									</c:forEach>
							    </div>
							    <div class="content">
							    	<ul>
							    		<li>
							    			<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="yearSum">
											    <thead>
											    	
												</thead>
										    	<tbody>
											    						
											    </tbody>
								    		</table>
							    		</li>
							    		<li>
							    			<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="abwqzhfz-1">
											    <thead>
													<th>年　　份</th>
													<th>项目数（项）</th>
													<th>完成数（项）</th>
													<th>未完成数（项）</th>
													<th>完成率（%）</th>
													<th>总投资（万元）</th>
													<th>部补助（万元）</th>
													<th>省区市自筹（万元）</th>
													<th>配套资金比例（%）</th>
												</thead>
										    	<tbody>
											    						
											    </tbody>
								    		</table>
							    		</li>
							    		<li>
							    			<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="abwqzhfz-2">
											    <thead>
											    	<th>年　　份</th>
													<th>项目数（项）</th>
													<th>完成数（项）</th>
													<th>未完成数（项）</th>
													<th>完成率（%）</th>
													<th>总投资（万元）</th>
													<th>部补助（万元）</th>
													<th>省区市自筹（万元）</th>
													<th>配套资金比例（%）</th>
												</thead>
										    	<tbody>
											    						
											    </tbody>
								    		</table>
							    		</li>
							    		<li>
							    			<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="abwqzhfz-3">
											    <thead>
											    	<th>年　　份</th>
													<th>项目数（项）</th>
													<th>完成数（项）</th>
													<th>未完成数（项）</th>
													<th>完成率（%）</th>
													<th>总投资（万元）</th>
													<th>部补助（万元）</th>
													<th>省区市自筹（万元）</th>
													<th>配套资金比例（%）</th>
												</thead>
										    	<tbody>
											    						
											    </tbody>
								    		</table>
							    		</li>
							    		<c:forEach items="${childMenuList}" var="menu"  varStatus="idxStatus">
							    			<li>
									    		<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="${menu.tag}">
											    	<thead>
											    		<th>序号</th>
												    	<th>操作</th>
												    	<th>发文单位</th>
												    	<th>上传用户</th>
												    	<th>文件名</th>
												    	<th>发文日期</th>
												    	<th>上传日期</th>
												    	<th>文件大小</th>
												    	<th>文件类型</th>
												    </thead>
										    		<tbody>
											    						
											    	</tbody>
									    		</table>
							    			</li>
							    		</c:forEach>
							        </ul>
							    </div>
							</div>
						</div>
					</div>
				</div>
				<div class="model">
					<div>
						<legend>五、检查评分</legend>
						<div class="content-title" id="checkResult">
						
						</div>
					</div>
				</div>
				<div class="model">
					<div class="content-btn">
						<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存" />
						&nbsp;&nbsp;&nbsp;&nbsp;
						<input id="btnCancel" class="btn" type="button" value="返 回" onclick="toBack()" />
					</div>
				</div>
			</div>
		</div>
	</form>
	<script src="${ctxStatic}/js/check/checkCommon.js" type="text/javascript"></script>
</body>
</html>